<template>
	<view style="padding: 20upx;background-color: #fff;">
		<textarea :value="int" @input="realnameIpt"  placeholder="请输入个人介绍" style="border: 1upx solid #999;border-radius: 20upx;width: 670upx;padding: 20upx;" />
		<view style="padding: 0 24upx;">
			<button type="primary" style="background: #EB2E15;margin-top: 20upx;" @click="submit">确认修改</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				openid:'',
				int:'',
			};
		},
		onLoad:function(e){
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../../login/login'
					});
				}
			});
		},methods:{
			setAjax(){
				uni.request({
					url: 'http://hszj.hongshantang696.com//app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.introduce&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						console.log(res)
						this.int = res.data.introduce
						uni.hideLoading()
					},
					fail: () => {},
					complete: () => {}
				});
			},
			realnameIpt(e){
				console.log(e.detail.value)
				this.int = e.detail.value
			},
			jump(e){
				uni.navigateTo({
					url: e.currentTarget.dataset.src
				});
			},
			submit(){
				var o = this
				uni.showLoading()
				uni.request({
					url:'http://hszj.hongshantang696.com//app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.introduce_sub&app=1',
					method: 'POST',
					data: {
						'openid':this.openid,
						'introduce': this.int,
					},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						uni.hideLoading()
						if(res.data.status == 1){
							uni.showToast({
								title: '修改成功',
								icon: 'none'
							});
							setTimeout(() =>{ // 正常返回
									uni.navigateBack();
								},300)
						}else{
							uni.showToast({
								title: res.data.result.message,
								icon:"none"
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style>

</style>
